export default {
    set (key, value) {
        let v = null
        if (typeof value === 'object') {
            try {
                v = JSON.stringify({ type: 'object', data: value })
            } catch (e) {
                console.log(v)
            }
        } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
            v = JSON.stringify({ type: 'string', data: value })
        }
        localStorage.setItem(key, v)
    },
    get (key) {
        const v = localStorage.getItem(key)
        try {
            const json = JSON.parse(v)
            return json.data
        } catch (e) {
            return null
        }
    },
    remove (key) {
        localStorage.removeItem(key)
    }
}
